/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

/**
 *
 * @author BlueZky
 */
public class Utils {
    public static String maHoa_MD5(String text) {
        String result = null;
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(text.getBytes());
            BigInteger bis = new BigInteger(1, md5.digest());
            result = bis.toString(64);
        } catch (NoSuchAlgorithmException ex) {
            System.out.println("khong the ma hoa duoc:" + ex.getMessage());
        }

        return result;
    }
    
    public static String generatePassword(){
        String result = "";
        result = UUID.randomUUID().toString();
        result = result.substring(0, 9);
        return result;
    }
}
